package com.lovo.sheyingback.controller;

import com.lovo.sheyingback.bean.form.SwiperForm;
import com.lovo.sheyingback.result.ResponseResult;
import com.lovo.sheyingback.service.SwiperService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@ResponseResult
@RequestMapping("/carousels")
@Tag(name = "轮播图管理SwiperController")
public class SwiperController {
    @Autowired
    private SwiperService swiperService;
    @GetMapping
    public Object listSwiper(SwiperForm swiperForm){
        return swiperService.listSwiper(swiperForm.getCurrent(),swiperForm.getPageSize());
    }
    @PostMapping
    public Object addSwiper(@RequestBody SwiperForm swiperForm){
        return swiperService.insertMore(swiperForm.getContentIds());
    }
    @PutMapping("/index/{id}")
    public Object updateIndex(@PathVariable Integer id,@RequestBody SwiperForm swiperForm){
        return swiperService.updateIndex(id,swiperForm.getVal());
    }
    @DeleteMapping("/{id}")
    public Object deleteSwiper(@PathVariable Integer id){
        return swiperService.delete(id);
    }
}
